package com.javaEE.gamepigeon.service.impl;


import com.javaEE.gamepigeon.dao.UserDao;
import com.javaEE.gamepigeon.entity.User;
import com.javaEE.gamepigeon.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserDao userDao;


    /**
     * 更新用户信息
     * @param user 用户对象
     * @return 是否更新成功的bool值
     */
    @Override
    public boolean updateUserDetail(User user) {
        user.setOpenId(((User) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getOpenId());
        return userDao.updateUserDetail(user) != 0;
    }
}
